import sys
from PySide6.QtWidgets import QApplication,  QPushButton, QVBoxLayout, QWidget, QMessageBox

class MessageDemo(QWidget):
    def __init__(self):
        super().__init__()

        v_box = QVBoxLayout(self)
        info_btn = QPushButton("消息")
        warn_btn = QPushButton("警告")
        talk_btn = QPushButton("对话")

        v_box.addWidget(info_btn)
        v_box.addWidget(warn_btn)
        v_box.addWidget(talk_btn)

        # 触发
        info_btn.clicked.connect(self.info_msg)
        warn_btn.clicked.connect(self.warn_msg)
        talk_btn.clicked.connect(self.talk_msg)
    
    def info_msg(self):
        msg = QMessageBox()
        msg.information(self, "消息", "我是一个消息")

    def warn_msg(self):
        msg = QMessageBox()
        msg.warning(self, "⚠", "我是一个警告")
    
    def talk_msg(self):
        rest = QMessageBox.question(self, "对话框", "确定关闭吗?", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
        if rest == QMessageBox.StandardButton.Yes:
            print("确定")
        else:
            print("取消")


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MessageDemo()
    window.show()
    sys.exit(app.exec())
